/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.fl.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.jeesite.modules.fl.entity.EvaluateDetail;
import com.jeesite.modules.fl.service.EvaluateDetailService;

/**
 * 评价明细表Controller
 * @author anthony
 * @version 2019-01-08
 */
@Controller
@RequestMapping(value = "${adminPath}/fl/evaluateDetail")
public class EvaluateDetailController extends BaseController {

	@Autowired
	private EvaluateDetailService evaluateDetailService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public EvaluateDetail get(String id, boolean isNewRecord) {
		return evaluateDetailService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("fl:appointment:evaluateView")
	@RequestMapping(value = {"list", ""})
	public String list(EvaluateDetail evaluateDetail, Model model) {
		model.addAttribute("evaluateDetail", evaluateDetail);
		return "modules/fl/evaluateDetailList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("fl:appointment:evaluateView")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<EvaluateDetail> listData(EvaluateDetail evaluateDetail, HttpServletRequest request, HttpServletResponse response) {
		Page<EvaluateDetail> page = evaluateDetailService.findPage(new Page<EvaluateDetail>(request, response), evaluateDetail); 
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("fl:appointment:evaluateView")
	@RequestMapping(value = "form")
	public String form(EvaluateDetail evaluateDetail, Model model) {
		model.addAttribute("evaluateDetail", evaluateDetail);
		return "modules/fl/evaluateDetailForm";
	}

	/**
	 * 保存评价明细表
	 */
	@RequiresPermissions("fl:appointment:evaluateEdit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated EvaluateDetail evaluateDetail) {
		evaluateDetailService.save(evaluateDetail);
		return renderResult(Global.TRUE, text("保存评价明细表成功！"));
	}
	
}